package com.neuedu.studentmanage.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.neuedu.studentmanage.entity.Homework;
import com.neuedu.studentmanage.entity.Pager;
import com.neuedu.studentmanage.entity.Result;
import com.neuedu.studentmanage.mapper.HomeworkMapper;
import com.neuedu.studentmanage.service.HomeworkService;

@Service
@Transactional
public class HomeworkServiceImpl implements HomeworkService{
	
	@Autowired
	private HomeworkMapper homeworkMapper;

	@Override
	public List<Homework> findListByPager(Pager<Homework> pager) {
		return homeworkMapper.findListByPager(pager);
	}

	@Override
	public Integer findTotalByPager(Pager<Homework> pager) {
		return homeworkMapper.findTotalByPager(pager);
	}

	@Override
	public Result add(Homework object) {
		Result result = new Result(false, "新增商品失败！");
		boolean ret = homeworkMapper.add(object);
		if (ret) {
			result = new Result(true, "新增商品成功！");
		}
		return result;
	}

	@Override
	public Result edit(Homework object) {
		Result result = new Result(false, "修改商品失败！");
		boolean ret = homeworkMapper.edit(object);
		if (ret) {
			result = new Result(true, "修改商品成功！");
		}
		return result;
	}

	@Override
	public Result deleteByIds(List<Homework> ids) {
		Result result = new Result(false, "删除商品失败！");
		boolean ret = homeworkMapper.deleteByIds(ids);
		if (ret) {
			result = new Result(true, "删除商品成功！");
		}
		return result;
	}

	@Override
	public List<Homework> findAll() {
		return homeworkMapper.findAll();
	}

}
